
$(function (){

    // 获取当前所有品牌
    $.ajax({
        url:"/brandManage/getBrandByConditionToProductPage2",
        type:"post",
        data:{},
        dataType: "json",
        success:function (result){
            if (result!=null){
                let str = "<option>请选择</option>";
                for (let i in result){
                    str += "<option>"+result[i].brandName+"</option>";
                }
                $(".brandName").html(str);
            }
        }
    })

    // 获取当前的全部商品类型
    $.ajax({
        url:"/productType/getTypesList",
        type:"post",
        data:{},
        dataType: "json",
        success:function (result){
            if (result!=null){
                let str = "<option>请选择</option>";
                for (let i in result){
                    str += "<option>"+result[i].typeName+"</option>";
                }
                $(".typeName").html(str);
            }
        }
    })

})

// 注销商品
function deleteProduct(){
    let b = confirm("确定要注销该商品么？");
    if (b){
        let typeName = $(".typeName2").html();
        let productModel = $(".productModel").html();
        $.ajax({
            url:"/productManage/deleteProduct",
            type:"post",
            data:{"typeName":typeName,"productModel":productModel},
            dataType:"json",
            success:function (result){
                if (result == true){
                    alert("删除成功");
                    location.reload();
                }else {
                    alert("删除失败");
                }
            }
        })
    }
}